<template>
	<view class="share-content">
		
		<!-- 分享文章列表 -->
		<view class="share-article">
			<!-- 标题 -->
			<view class="title-tab">
				<view class="hot" @click="setActive(1)">
					<view class="title" :class="{'active':titleTabNum == '1'}">我的笔记</view>
					<view class="underline" :class="{'active':titleTabNum == '1'}"></view>
				</view>
				<view class="new" @click="setActive(2)">
					<view class="title" :class="{'active':titleTabNum == '2'}">收藏的笔记</view>
					<view class="underline" :class="{'active':titleTabNum == '2'}"></view>
				</view>
			</view>
			<!-- 文章列表 -->
			<view class="article-list">		
				<view class="note-box" v-if="no_note">
					<image lazy-load="true"  src="../../static/images/nonote.png" mode="widthFix" class="no-note"></image>
				</view>
				<view class="article" v-for="(item,key) in note_list" :key="key" @click="goNoteDetail(item.id)">
					<view class="article-img">
						<image lazy-load="true"  :src="item.images.image" mode="w" class="article-img"></image>
					</view>
					<view class="title">{{item.title}}</view>
					<view class="author">
						<view class="author-info">
							<view class="ico"><image lazy-load="true"  :src="item.user_info.avatar" class="ico"></image></view>
							<view class="name">{{item.user_info.nickname}}</view>
						</view>
						<!-- <view class="share">
							<view class="text">现金200+</view>
							<view class="share-ico">
								<image lazy-load="true"  src="../../static/images/article-share-ico.png" class="share-ico"></image>
							</view>
						</view> -->
					</view>
					<view class="info">
						<view class="good"><view>点赞</view><view class="good-num">{{item.like_count}}</view></view>
						<view class="discuss"><view>评论</view><view class="discuss-num">{{item.comment_count}}</view></view>
						<view class="see"><view>浏览</view><view class="see-num">{{item.scan_count}}</view></view>						
					</view>	
				</view>	
			</view>
		</view>
	</view>
</template>

<script>
	// 瀑布流组件
	
	export default {
		data() {
			return {
				titleTabNum:'1',
				"checked":true,
				"checkAllSta":false,
				note_list:[],
				no_note:false
			}
		},
		onLoad() {
			let self = this;
			this.getNoteList();
			// #ifdef H5
			let share_time_line={
				title:self.$request.h5_share_name, // 分享标题
				link: self.$request.h5_share_url+'?page=index', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				imgUrl: self.$request.h5_img_url+'/static/images/logo.png', // 分享图标
			}
			let share_app_message={
				title: self.$request.h5_share_name, // 分享标题
				desc: '我发现了一个很不错的商城，买家具有超大实惠！', // 分享描述
				link: self.$request.h5_share_url+'?page=index', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				imgUrl: self.$request.h5_img_url+'/static/images/logo.png', // 分享图标
			}
			uni.setStorageSync('share_time_line',share_time_line);
			uni.setStorageSync('share_app_message',share_app_message);
			self.$request.wx_config()
			// #endif
		},
		onShareAppMessage(res) {
		    if (res.from === 'button') {
		      console.log(res.target)
		    }
		    return {
		      title: this.$request.share_title,
		      path: '/pages/index/index'
		    }
		  },
		methods: {
			setActive(num){
				this.titleTabNum = num;
				if(num==1){
					this.getNoteList()
				}else{
					this.getLikeNoteList()
				}
			},
			checkImg(){
				this.checked = !this.checked
			},
			checkAll(){
				this.checkAllSta = !this.checkAllSta
			},
			getNoteList(){
				var self = this;
				self.$request.request({
					url:'/user/note/list',
					data:{
						'per':10000
					},
					success:function(res){
						console.log(res)
						if(res.code==200){
							var x = res.result;
							self.note_list = x;
							if(self.note_list.length<1){
								self.no_note = true
							}else{
								self.no_note = false
							}
						}else{
							
						}
					}
				})
			},
			getLikeNoteList(){
				var self = this;
				self.$request.request({
					url:'/user/collection/list',
					data:{
						'per':10000
					},
					success:function(res){
						console.log(res)
						if(res.code==200){
							var x = res.result;
							console.log(x)
							self.note_list = x;
							if(self.note_list.length<1){
								self.no_note = true
							}else{
								self.no_note = false
							}
							
						}else{
							
						}
					}
				})
			},
			goNoteDetail(id){
				uni.redirectTo({
					url:'../share-details/share-details?id='+id
				})
			}
			
		}
	}
</script>

<style>
	@import url("my-note.css");
</style>
